package hw.ats.news.ui;

import hw.ats.news.R;
import hw.ats.news.model.Cate;

import java.util.ArrayList;
import java.util.List;

import android.widget.Button;
import android.widget.ImageButton;

public class CateNavHolder {
	public final List<Button> views;
	private final List<Cate> cateList;
	public ImageButton prevBtn;
	public ImageButton nextBtn;
	
	public CateNavHolder(List<Cate> cateList) {
		this.views = new ArrayList<Button>();
		this.cateList = cateList;
	}
	
	public void deselect() {
		for (int i = 0, len = cateList.size(); i < len; i++) {
			Button v = views.get(i);
			v.setBackgroundResource(R.drawable.bg_catbar);
			v.setTextColor(0xff666666);
		}
	}
	
	public Cate select(int position) {
		deselect();
		
		Button v = views.get(position);
		v.setBackgroundResource(R.drawable.bg_catbar_on);
		v.setTextColor(0xffffffff);
		Cate c = cateList.get(position);
		return c;
	}
}
